package net.sppan.base.dao;

import net.sppan.base.dao.support.IBaseDao;
import net.sppan.base.entity.DyContentComment;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional(isolation = Isolation.READ_COMMITTED)
public interface IDyContentCommentDao extends IBaseDao<DyContentComment, Long>{

	@Modifying
	@Query(value ="update DyContentComment set commentType=:status   where commentId =:commentId")
	void updateContentComment(@Param("commentId") Long commentId,@Param("status") Long status);
	
	
	@Query(value="FROM DyContentComment where commentId >:commentId and (commentType in (1,2) or type <> 0 ) "
			,countQuery ="select count(*) FROM DyContentComment where commentId >:commentId and (commentType in (1,2) or type <> 0 ) "	)
	Page<DyContentComment> findContentComment(@Param("commentId") Long commentId, Pageable pageable);
}
